package nc.bs.common.util;

import nc.bs.dao.DAOException;
import nc.bs.pub.util.BaseDaoUtil;
import nc.jdbc.framework.processor.ColumnProcessor;

/**
 * @author duanyp1
 * @date 2024/2/22 15:29
 */
public class OrgQueryUtil {


    public static String getOrgCodeByPK(String pk_org) {
        return queryOrg("code", "pk_org", pk_org);
    }

    public static String getPkOrgByCode(String code) {
        return queryOrg("pk_org", "code", code);
    }

    public static String queryOrg(String targetColumn, String key, String value) {
        String sql = "SELECT " + targetColumn + " FROM org_orgs where dr = 0 and isbusinessunit = 'Y' and " + key + " = '" + value + "'";
        try {
            return (String) BaseDaoUtil.getInstance().executeQuery(sql, new ColumnProcessor());
        } catch (DAOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
